package com.cs.store.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cs.domain.entity.UserInfo;
import com.cs.store.dao.IStoreDao;
import com.cs.store.service.IStoreService;
import com.cs.common.result.HttpResp;
import com.cs.common.result.ResultCode;
import com.cs.domain.entity.Store;
import com.cs.user.dao.IUserInfoDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/store")
public class StoreController {
    @Autowired
    private IStoreService iStoreService;

    @Autowired
    private IStoreDao iStoreDao;

    /**
     * 展示所有门店
     * @return
     */
    @GetMapping("findAllStore")
    public HttpResp findAllStore() {
        List<Store> allStore = iStoreService.findAllStore();
        return HttpResp.result(ResultCode.STORE_SHOW, new Date(),allStore);
    }

    /**
     * 展示商品类型
     * @return
     */
    @GetMapping("findAllType")
    public HttpResp findAllType() {
//        List<Store> allStore = iStoreService.findAllStore();
        return HttpResp.result(ResultCode.GOODS_TYPE_SHOW, new Date(),iStoreService.findAllType());
    }


    /**
     * 展示所有商品
     * @return
     */
    @GetMapping("findGoodsBySt")
    public HttpResp findGoodsBySt(String storename,String typeName) {
        return HttpResp.result(ResultCode.STORE_GOODS_SHOW, new Date(),iStoreService.findGoodsBySt(storename,typeName));
    }

    @GetMapping("/findStoreInfo")
    public HttpResp findStoreInfo(String username){
        return HttpResp.result(ResultCode.USER_QUERY_SUCCESS,new Date(),iStoreService.findStoreInfo(username));
    }

    /**
     * 根据用户id获取店铺id
     * @param storeUserName
     * @return
     */
    @GetMapping("/findTheStoreId")
    public HttpResp findTheStoreId(String storeUserName){
        return HttpResp.result(ResultCode.USER_LOGIN_SUCCESS,new Date(),iStoreService.findTheStoreId(storeUserName));
    }

}
